package com.yf.tz.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import java.util.Map;
import com.yf.consts.DaoConst;
import com.yf.tz.entity.AccountEntity;
import com.yf.tz.service.AccountService;
import com.yf.response.R;


/**
 * 账户信息Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Wed Jul 01 16:32:18 CST 2020
 */
@RestController
@RequestMapping("/account")
public class AccountController {
    @Autowired
    private AccountService accountService;

    /**
     * 列表账户信息
     */
    @SysLog("查看账户信息")
    @RequestMapping("/list")
    @RequiresPermissions("account:list")
    public R list(@RequestParam Map<String,Object> params) {
        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<AccountEntity> accountList = accountService.queryList(params);
        return R.ok(new PageInfo(accountList));
    }

    /**
     * 查看账户信息
     */
    @SysLog("查看账户信息")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("account:info")
    public R info(@PathVariable("id") Long id) {
        AccountEntity account = accountService.get(id);

        return R.ok(account);
    }

    /**
     * 保存账户信息
     */
    @SysLog("保存账户信息")
    @RequestMapping("/save")
    @RequiresPermissions("account:save")
    public R save(AccountEntity account) {
        accountService.save(account);

        return R.ok(account);
    }

    /**
     * 修改账户信息
     */
    @SysLog("修改账户信息")
    @RequestMapping("/update")
    @RequiresPermissions("account:update")
    public R update(AccountEntity account) {
        accountService.update(account);

        return R.ok(account);
    }

    /**
     * 删除账户信息
     */
    @SysLog("删除账户信息")
    @RequestMapping("/delete")
    @RequiresPermissions("account:delete")
    public R delete(Long[]ids) {
        accountService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有账户信息
     */
    @SysLog("所有账户信息")
    @RequestMapping("/all")
    public R queryAll (@RequestParam Map<String,Object> params) {

        List<AccountEntity> accountList = accountService.queryList(params);

        return R.ok(accountList);
    }

    /***********自定义开始***********/




}
